package com.ag.lwc.action;

import java.util.LinkedList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.ag.bean.TbEventStatus;
import com.ag.common.BaseAction;
import com.ag.lwc.service.EventStatuService;

@Controller("EventStatuAction")
public class EventStatuAction extends BaseAction 
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Resource(name="EventStatuService")
	private EventStatuService service;
	private List<TbEventStatus> result = new LinkedList<TbEventStatus>();
	private String tbesId;
	private String tbesEventStatus;
	private String tbesColor;
	private String message;
	
	public String find()
	{
		result = service.findAll();
		message = "find_success";
		return "find_success";
	}
	public String modify()
	{
		TbEventStatus ebEventStatus = new TbEventStatus();
		ebEventStatus.setTbesId(tbesId);
		ebEventStatus.setTbesColor(tbesColor);
		ebEventStatus.setTbesEventStatus(tbesEventStatus);
		try
		{
			service.update(ebEventStatus);
			message="change_success";
			
		}
		catch(Exception e)
		{
			message="修改失败";
			
		}
		return "change_success";
	}
	public String save()
	{
		TbEventStatus ebEventStatus = new TbEventStatus();
		ebEventStatus.setTbesId(tbesId);
		ebEventStatus.setTbesEventStatus(tbesEventStatus);
		ebEventStatus.setTbesColor(tbesColor);
		try
		{
			
			service.save(ebEventStatus);
			message="save_success";
			
		}
		catch(Exception e)
		{
			message="保存失败";
			
		}
		return "save_success";
	}
	public String delete()
	{
		try
		{
			service.delete(tbesId);
			message = "delete_success";
			
		}
		catch(Exception e)
		{
			message="删除失败";
			
		}
		return "delete_success";
	}
	public String execute()
	{
		result = service.findAll();
		return "success";
	}
	public List<TbEventStatus> getResult() {
		return result;
	}
	public void setService(EventStatuService service) {
		this.service = service;
	}
	public String getMessage() {
		return message;
	}
	public void setTbesId(String tbesId) {
		
		this.tbesId = tbesId;
		
	}
	public void setTbesEventStatus(String tbesEventStatus) {
		this.tbesEventStatus = tbesEventStatus;
	}
	public void setTbesColor(String tbesColor) {
		this.tbesColor = tbesColor;
	}
	
}
